﻿using System;
using System.Collections.ObjectModel;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using MSSQL.DBSync.UI.Common.AsyncCmds;
using MSSQL.DBSync.UI.Common.Messages;
using MSSQL.DBSync.UI.Components.MainWindow;
using MSSQL.DBSync.UI.Components.MakeComparsion;
using MSSQL.DBSync.UI.Components.MakeSnapshot;

namespace MSSQL.DBSync.UI.Components.MainChoice
{
    public class MainChoiceVM : ViewModelBase , IMainChoiceVM
    {

        public MainChoiceVM()
        {
            initDesignData();
        }

        /// <summary>
        /// 初始化设计数据
        /// </summary>
        private void initDesignData()
        {
            Menus.Add(new SideMenuVO { Name = "数据结构快照", ContentKey = typeof(IMakeSnapshotView) });
            Menus.Add(new SideMenuVO { Name = "数据库升级", ContentKey = typeof(IMakeComparsionView) });
        }

        public ObservableCollection<SideMenuVO> Menus { get; set; } = new ObservableCollection<SideMenuVO>();


        private RelayCommand<SideMenuVO> mGotoPage;
        /// <summary>
        /// 跳转页面
        /// </summary>
        public RelayCommand<SideMenuVO> GotoPage
        {
            get
            {
                //非空判断
                if (mGotoPage != null) { return mGotoPage; }
                mGotoPage = new RelayCommand<SideMenuVO>((CurMenuItem) => {
                        Messenger.Default.Send(CurMenuItem.ContentKey, MessageTopics.APP_GotoPage);
                    }
                );
                return mGotoPage;
            }
            set { mGotoPage = value; }
        }
    }

}